import asyncio
import aioredis


async def execute(address,password):
    print("开始执行...",address)
    redis = await aioredis.create_redis(address,password=password)
    await redis.set('name',address)
    rs = await redis.get('name')
    print(rs)
    redis.close()
    await redis.wait_closed()
    print("结束",address)

async def main():
    tasks = [
        asyncio.create_task(execute('redis://127.0.0.1:6379','123456')),
        asyncio.create_task(execute('redis://127.0.0.1:6380','123456'))
    ]
    await asyncio.wait(tasks)
if __name__ == "__main__":
    asyncio.run(main())